<?php
/**
 * Created by PhpStorm.
 * User: Jason
 * Date: 2017/8/8
 * Time: 23:35
 */

namespace Admin\Service;


class UserMemberService
{
    /**
     * 获取会员 收费的设置
     * @return mixed
     */
    public function getChargeSet()
    {
        $model = M('UserCoinCharge');
        $map = array(
            'is_delete'=>0
        );
        $chargeSet = $model->where($map)->select();
        return $chargeSet;
    }

    /**
     * 添加会员收费设置
     * @return mixed
     */
    public function addChargeSet()
    {
        $param = I('post.');
        $model = M('UserCoinCharge');
        $data = $model->create($param);

        if ($data) {
            //填充参数
            $param['creator_id'] = UID;
            $param['create_time'] = date('YmdHis', time());

            $id = $model->add($param);
            return $id;
        } else {
            E($model->getError());
        }
    }

    /**
     * 编辑会员收费设置
     */
    public function editChargeSet()
    {
        $param = I('post.');
        $model = M('UserCoinCharge');
        $data = $model->create($param);
        if ($data) {
            $param['updator_id'] = UID;
            $param['update_time'] = date('YmdHis', time());
            $res = $model->where(array('id'=>$param['id']))->save($param);
            return $res;
        } else {
            E($model->getError());
        }
    }
}